package com.cheng.gmall.item;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnel;
import com.google.common.hash.Funnels;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package com.cheng.gmall.item
 * @date 2024/5/29 下午9:32
 */
public class Bloomtest {
    @Test
    void bloomtest(){
        Funnel<CharSequence> funnel = Funnels.stringFunnel(StandardCharsets.UTF_8);
        BloomFilter<CharSequence> filter = BloomFilter.create(funnel, 1000000, 0.000001);
        filter.put("http://www.baidu.com");
        filter.put("http://www.qq.com");
        filter.put("http://www.jd.com");


        String url="http://www.atguigu.com";
        //判定可能包含;判定为否
        System.out.println(filter.mightContain(url));
    }
}
